package com.baidu.service.impl;

import com.baidu.utils.ResultResponse;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baidu.pojo.TbBrand;
import com.baidu.service.TbBrandService;
import com.baidu.mapper.TbBrandMapper;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class TbBrandServiceImpl extends ServiceImpl<TbBrandMapper, TbBrand>
    implements TbBrandService{
    @Autowired
    TbBrandMapper tbBrandMapper;

    @Override
    public ResultResponse findTbBrandList(Integer pageNum,Integer pageSize) {
        Page<TbBrand> page = new Page<>(pageNum, pageSize);
        Page<TbBrand> tbBrandPage = tbBrandMapper.selectPage(page, null);
        return ResultResponse.SUCCESS(tbBrandPage);
    }

    @Override
    public void saveTbBrand(TbBrand tbBrand) {
        tbBrandMapper.insert(tbBrand);
    }

    @Override
    public TbBrand queryTbBrandById(Long id) {
        return tbBrandMapper.selectById(id);
    }

    @Override
    public void updateTbBrand(TbBrand tbBrand) {
        tbBrandMapper.updateById(tbBrand);
    }

    @Override
    public ResultResponse delTbBrandById(List<TbBrand> ids) {
        for (TbBrand brand : ids) {
            tbBrandMapper.deleteById(brand.getId());
        }
        return ResultResponse.SUCCESS();
    }

    @Override
    public List<TbBrand> findList() {
        return tbBrandMapper.selectList(null);
    }


}




